package com.cskaoyan.controller;

import com.cskaoyan.bean.BO.IssueCreateBo;
import com.cskaoyan.bean.PO.MarketIssue;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdminIssueService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminIssueController
 * @Description TODO
 * @Author ke
 * @Date 2022/8/13 15:43
 * @Version 1.0
 */
@RestController
@RequestMapping("admin/issue")
public class AdminIssueController {

    @Autowired
    AdminIssueService adminIssueService;

    @RequiresPermissions("admin:issue:list")
    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info,String question){
        CommonData<MarketIssue> issueCommonData=adminIssueService.list(info,question);
        return BaseRespVo.ok(0,issueCommonData,"成功");
    }

    @RequiresPermissions("admin:issue:create")
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody IssueCreateBo bo) {
        MarketIssue marketIssue=adminIssueService.create(bo);
        return BaseRespVo.ok(0,marketIssue,"成功");
    }

    @RequiresPermissions("admin:issue:update")
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketIssue bo){
        MarketIssue marketIssue=adminIssueService.update(bo);
        return BaseRespVo.ok(0,marketIssue,"成功");
    }

    @RequiresPermissions("admin:issue:delete")
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketIssue bo){
        MarketIssue marketIssue=adminIssueService.delete(bo);
        return BaseRespVo.ok(0,marketIssue,"成功");
    }
}
